package com.xiaowen.service;

import com.xiaowen.dao.UserMapper;
import com.xiaowen.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by 15c on 2017/11/15.
 */
@Service("UserBean")
public class UserServiceImpl implements UserService {
    @Autowired
    UserMapper userMapper;

    /**
     * 通过email来注册
     * @param user
     * @return
     */
    @Override
    public int addUserByEmail(User user) {
        return userMapper.insertByEmail(user);
    }

    @Override
    public int addUserByPhone(User user) {
        return userMapper.insertByPhone(user);
    }

    @Override
    public User showUser(User user) {
        return userMapper.selectIdByuserEmail(user);
    }

    @Override
    public User showUserByPhone(User user) {
        return userMapper.selectIdByuserPhone(user);
    }

    @Override
    public User login(String email) {
        return userMapper.selectIdByuserEmailLogin(email);
    }

    @Override
    public int updateUser(User user) {
        return userMapper.update(user);
    }

    @Override
    public User selectUserPartInfoByUserId(Integer userId) {
        return userMapper.selectUserInfo(userId);
    }


    @Override
    public int addUser(User user) {
        return userMapper.insertSelective(user);
    }

    @Override
    public User showUser(int id) {
        return  userMapper.selectByPrimaryKey(id);
    }
}
